#include<bits/stdc++.h>
using namespace std;
int n,r[100005],cnt,h[100005];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",r+i),h[r[i]]++;
    sort(r+1,r+n+1);
    int i=1,j=1+h[r[1]];
    while(i<n && j<=n){
        if(n-j+1>=h[r[i]])
            cnt+=h[r[i]],i+=h[r[i]],j+=h[r[i]];
        else{
            cnt+=n-j+1;
            break;
        }
        if(j<=i+h[r[i]]-1)
            j=i+h[r[i]];
    }
    printf("%d",n-cnt);
    return 0;
}
